﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace HRM.Web.master
{
    public partial class AddJobTitles : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                GetDataByJobID();
            }
        }


        #region Page methods

        private void GetDataByJobID()
        {
            if (Request.QueryString["JobTitleID"] != null && Request.QueryString["JobTitleID"] != "")
            {
                BLL.Login objLogin = new BLL.Login();
                DataTable dt = objLogin.SelectByID(Convert.ToInt32(Request.QueryString["JobTitleID"]));
                if (dt.Rows.Count > 0)
                {
                    txtJobTitle.Text = dt.Rows[0][""].ToString();
                    txtJobDescription.Text = dt.Rows[0][""].ToString(); ;
                    txtNote.Text = dt.Rows[0][""].ToString();
                    hdnID.Value = dt.Rows[0]["ID"].ToString();
                }
                else
                {
                    ClearFields();
                }
            }
        }
        #endregion

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("ManageJobTitles.aspx" + BLL.Common.GetQueryStringValues());
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            divAlert.Visible = false;
            //BO.Users BO_objLogin = new BO.Users();
            //BO_objLogin.ID = Convert.ToInt32(hdnID.Value.Trim());
            //BO_objLogin.LoginName = txtJobTitle.Text.Trim();
            //BO_objLogin.EmailID = txtJobDescription.Text.Trim();
            //BO_objLogin.LoginPassword = txtNote.Text.Trim();


            //BLL.Login BLL_objLogin = new BLL.Login();
            //BLL_objLogin.Save(BO_objLogin);
            //divAlert.Visible = true;
            //if (BO_objLogin.ID == 0)
            //{
            //    //ltrMessage.Text = "This record has been saved successfully.";
            //}
            //else
            //{
            //    //ltrMessage.Text = "This record has been updated successfully.";
            //}
            Response.Redirect("ManageJobTitles.aspx" + BLL.Common.GetQueryStringValues());
            //ClearFields();
        }
        private void ClearFields()
        {
            hdnID.Value = "0";

        }
    }
}
